package com.topboya.linker.ui.activity;

import android.content.Intent;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.flyco.tablayout.SlidingTabLayout;
import com.google.gson.internal.bind.ArrayTypeAdapter;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.topboya.linker.R;
import com.topboya.linker.model.levelitem.OrgLevel0Item;
import com.topboya.linker.model.response.CustomerByOrgIdAndNewlyCusListResopnse;
import com.topboya.linker.model.response.CustomerByOrgIdResponse;
import com.topboya.linker.model.response.DictByKeyResponse;
import com.topboya.linker.model.response.NewlyOrgListResponse;
import com.topboya.linker.model.response.OrganizationResopnse;
import com.topboya.linker.ui.adapter.CustomerAdapter;
import com.topboya.linker.ui.adapter.CustomerExpandableItemAdapter;
import com.topboya.linker.ui.base.activity.BaseActivity;
import com.topboya.linker.ui.base.adapter.CommonFragmentPagerAdapter;
import com.topboya.linker.ui.base.fragment.BaseFragment;
import com.topboya.linker.ui.fragment.AuditedFragment;
import com.topboya.linker.ui.fragment.NotifyMsgFragment;
import com.topboya.linker.ui.fragment.NotifyNoticeFragment;
import com.topboya.linker.ui.fragment.UnAuditedFragment;
import com.topboya.linker.ui.presenter.CustomerPresenter;
import com.topboya.linker.ui.view.CustomerView;
import com.topboya.linker.utils.LogUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class xCustomerActivity extends BaseActivity<CustomerView, CustomerPresenter> implements CustomerView {

    private static final String TAG = "CustomerActivity-";
    private Toolbar toolbar;
    private TextView toolbar_title;
    private TextView tv_toolbar_right;
    private SlidingTabLayout tab_customer_label;
    private ViewPager vp_custom_content;


    @Override
    protected int getLayoutId() {

        return R.layout.activity_xustomer;
    }

    @Override
    protected void initView() {

        toolbar = findViewById(R.id.toolbar);
        toolbar_title = findViewById(R.id.toolbar_title);
        tv_toolbar_right = findViewById(R.id.tv_toolbar_right);
        tab_customer_label = findViewById(R.id.tab_customer_label);
        vp_custom_content = findViewById(R.id.vp_custom_content);
        toolbar_title.setText("终端信息");
        tv_toolbar_right.setText("新增");

    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);

        LogUtils.v(TAG + "onNewIntent()");
        initData();

    }

    @Override
    protected void initData() {


        ArrayList<BaseFragment> fragmentList = new ArrayList<>();
        fragmentList.add(new AuditedFragment());
        fragmentList.add(new UnAuditedFragment());
        CommonFragmentPagerAdapter commonFragmentPagerAdapter = new CommonFragmentPagerAdapter(getSupportFragmentManager(),fragmentList);
        vp_custom_content.setAdapter(commonFragmentPagerAdapter);
        tab_customer_label.setViewPager(vp_custom_content,new String[]{"已审核","未审核"});
    }

    @Override
    protected void initListener() {

        tv_toolbar_right.setOnClickListener(v -> jumpToActivity(AddDeviceActivity.class));
        toolbar.setNavigationOnClickListener(v -> { finish(); });


    }

    @Override
    protected CustomerPresenter createPresenter() {

        return new CustomerPresenter(this);
    }


    @Override
    public void setCustomeData(ArrayList<OrganizationResopnse.DocDetailInfoList> groupList,ArrayList<NewlyOrgListResponse.Data> groupHListNewly) { }



    @Override
    public void setDepartment(List<CustomerByOrgIdResponse.DepartmentList> departmentlist) {

        LogUtils.v(TAG +"setDepartment()");

    }

    @Override
    public void setDictByKey(List<DictByKeyResponse.Data> data) {

    }

    @Override
    public void createCustomer() {


    }

    @Override
    public void setDepartVisitor(HashMap<String, List<CustomerByOrgIdAndNewlyCusListResopnse.CusListChild>> departmentgroupmap, List<CustomerByOrgIdAndNewlyCusListResopnse.NewlyCusList> newlyCusLists) {

    }



    private ArrayList<MultiItemEntity> generateData(ArrayList<OrganizationResopnse.DocDetailInfoList> groupList) {

        ArrayList<MultiItemEntity> res = new ArrayList<>();

        for (int i = 0; i < groupList.size(); i++) {

            OrgLevel0Item lv0 = new OrgLevel0Item();
            lv0.setHaspatialname(groupList.get(i).getOrgName());
            lv0.setGetHaspatialevel(groupList.get(i).getLevelName());
            lv0.setOrgID(groupList.get(i).getId());
            res.add(lv0);
        }
        return res;
    }
}
